<template>
  <div class="receiving-area">
    <div class="title">{{ passData.username }}</div>
    <div class="table-wrapper">
      <vxe-table border :loading="loading" show-overflow="title" height="100%" :data="tableData" :scroll-y="{ enabled: true, gt: 50 }">
        <vxe-column field="provinceName" title="省"></vxe-column>
        <vxe-column field="cityName" title="市"></vxe-column>
        <vxe-column field="areaName" title="区"></vxe-column>
        <vxe-column field="streetName" title="街道"></vxe-column>
      </vxe-table>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { toRefs, watch } from "vue";
import InitHook from "./composables/initHook";
import { getAreaByUserIdApi } from "@/api/managementCenter/driverManagement";
const props = withDefaults(
  defineProps<{
    visible: boolean;
    passData: DriverManagement.ListRows;
  }>(),
  {}
);
const { visible, passData } = toRefs(props);
const { tableData, loading } = InitHook();
const init = () => {
  loading.value = true;
  getAreaByUserIdApi(passData.value.userId)
    .then((res: any) => {
      const { code, data } = res;
      if (code === 200) {
        tableData.value = data || [];
      }
    })
    .finally(() => (loading.value = false));
};
watch(
  () => visible.value,
  (v: boolean) => {
    if (v) {
      init();
    }
  }
);
init();
</script>
<style lang="stylus" scoped>
.receiving-area{
    height: 100%;
    .title {
        font-size: 16px;
        font-weight: 600;
        padding-bottom: 12px;
    }
    .table-wrapper{
        height: calc(100% - 50px);
    }
}
</style>
